<template>

  <el-tabs v-model="activeName" style="padding-left: 8px;" @tab-click="handleClick">
    <el-tab-pane :key="'first'" label="培训计划" name="first">
      <child1 v-if="isChildUpdate1" />
    </el-tab-pane>

    <el-tab-pane :key="'second'" label="考试" name="second">
      <child2 v-if="isChildUpdate2" />
    </el-tab-pane>
  </el-tabs>

</template>

<script>
import trainPlan from '@/views/psp/safeTrain/trainPlan'
import trainExamination from '@/views/psp/safeTrain/trainExamination'
export default {
  name: 'TrainPlan',
  components: {
    child1: trainPlan,
    child2: trainExamination
  },
  data() {
    return {
      // 默认第一个选项卡
      activeName: 'first',
      isChildUpdate1: true,
      isChildUpdate2: false
    }
  },
  mounted() {

  },
  methods: {
    handleClick(tab) {
      if (tab.name === 'first') {
        this.isChildUpdate1 = true
        this.isChildUpdate2 = false
      } else if (tab.name === 'second') {
        this.isChildUpdate1 = false
        this.isChildUpdate2 = true
      }
    }
  }
}
</script>
